<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" 
      xmlns:ui="http://java.sun.com/jsf/facelets" 
      xmlns:h="http://java.sun.com/jsf/html" 
      xmlns:t="http://myfaces.apache.org/tomahawk"
      xmlns:f="http://java.sun.com/jsf/core">
    <h:body>
    	<ui:composition template="./templates/framework.xhtml">
			<ui:define name="content">
				<ui:include src="./templates/header.xhtml">
					<ui:param name="text" value="#{i18n['generic.back']}" />
					<ui:param name="link" value="listshares.xhtml" />
				</ui:include>
				<script type="text/javascript">
					var fieldInformation = {
						message: {placeholder: "#{i18n['share.placeholderMessage']}", optional: true},
						email: {placeholder: "#{i18n['share.placeholderEmail']}", optional: true}
					};
				</script>
				<p>
					<h:outputText value="#{i18n['share.text']}" />
				</p>
				<ui:fragment rendered="#{!sessionBean.user.confirmed}">
					<p>
						<h:outputText value="#{i18n['share.errorConfirmation']}" escape="false" />
					</p>
				</ui:fragment>
				<ui:fragment rendered="#{sessionBean.user.confirmed and !(sessionBean.user.name != '')}">
					<p>
						<h:outputText value="#{i18n['share.errorProfile']}" escape="false" />
					</p>
				</ui:fragment>
				<ui:fragment rendered="#{sessionBean.user.confirmed and sessionBean.user.name != ''}">
					<h:form id="addShareRequestForm" styleClass="primary">
						<div>
							<h:outputLabel for="email" value="#{i18n['generic.email']}" />
							<h:inputText id="email" value="#{addShareRequestBean.email}" required="true" requiredMessage="#{i18n['share.valueRequired']}">
								<f:validator validatorId="validateEmail" />
							</h:inputText>
							<span class="error"><h:message for="email" /></span>
						</div>
						<div>
							<h:outputLabel for="accessRight" value="#{i18n['share.right']}" />
							<h:selectOneMenu id="accessRight" value="#{addShareRequestBean.accessRight}">
								<f:selectItem itemLabel="#{i18n['share.readOnly']}" itemValue="READ_ONLY" />
								<f:selectItem itemLabel="#{i18n['share.readWrite']}" itemValue="READ_WRITE" />
								<f:selectItem itemLabel="#{i18n['share.owner']}" itemValue="OWNER" />
							</h:selectOneMenu>
							<span class="error"><h:message for="accessRight" /></span>
						</div>
						<div>
							<h:outputLabel for="message" value="#{i18n['share.message']}" />
							<h:inputTextarea id="message" value="#{addShareRequestBean.message}" />
							<span class="error"><h:message for="message" /></span>
						</div>
						<div class="buttons">
							<h:commandButton type="submit" value="#{i18n['share.send']}" action="#{addShareRequestBean.sendInvitation}" />
							<input type="button" value="#{i18n['generic.cancel']}" onclick="location.href='listshares.xhtml'" />
						</div>
					</h:form>
				</ui:fragment>
			</ui:define>
		</ui:composition>
    </h:body>
</html>